a = []
for j in range(100,1000):
    k = 0
    for i in range(2,j//2+1):
        if j % i == 0:
            k+=1 
    if k == 0:
        a.append(j)
print(a)
b = ["zero", "one", "two", "three", "four", "five", "six","seven", "eight", "nine"]
print(b.index("zero"))
vse = input()
if len(vse.split()) == 3:
    sot,des,edin = vse.split()
    if sot in b and des in b and edin in b:
        if sot == "zero":
            print("трехзначное не начинается с нуля!")
        else:
            chislo = b.index(sot)*100 + b.index(des)*10+b.index(edin)
            mmenshe = 0 
            mbolshe = 10000
            for i in a:
                if i <= chislo:
                    mmenshe = i
                if i >= chislo and mbolshe == 10000:
                    mbolshe = i
            print(mbolshe,chislo,mmenshe)
            if chislo - mmenshe > mbolshe-chislo:
 
                print(mbolshe)
            else:
                print(mmenshe)
    else:
        print("Wrong!")
else:
    print("Wrong!")
 